﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace SimTank
{
    public partial class SimTankMainWindow : Form
    {

        private void List_DrawItem(object sender, DrawListViewItemEventArgs e)
        {
            if ((e.State & ListViewItemStates.Selected) != 0)
            {
                // Draw the background and focus rectangle for a selected item.
                e.Graphics.FillRectangle(Brushes.Blue, e.Bounds);
                e.DrawFocusRectangle();
            }
            else
            {
                e.Graphics.FillRectangle(Brushes.White, e.Bounds);
            }
        }

        private void List_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
        {

            if ((e.ItemState & ListViewItemStates.Selected) != 0)
            {
                e.Graphics.DrawString(e.SubItem.Text, e.Item.Font, Brushes.White, e.Bounds.Location);
            }
            else
            {
                e.Graphics.DrawString(e.SubItem.Text, e.Item.Font, Brushes.Black, e.Bounds.Location);
            }

        }

        private void List_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
        {
            using (StringFormat sf = new StringFormat())
            {
                // Store the column text alignment, letting it default
                // to Left if it has not been set to Center or Right.
                switch (e.Header.TextAlign)
                {
                    case HorizontalAlignment.Center:
                        sf.Alignment = StringAlignment.Center;
                        break;
                    case HorizontalAlignment.Right:
                        sf.Alignment = StringAlignment.Far;
                        break;
                }

                // Draw the standard header background.
                e.DrawBackground();

                // Draw the header text.
                using (Font headerFont =
                            new Font("Helvetica", 10, FontStyle.Bold))
                {
                    e.Graphics.DrawString(e.Header.Text, headerFont,
                        Brushes.Black, e.Bounds, sf);
                }
            }
            return;
        }

        private void List_MouseMove(object sender, MouseEventArgs e)
        {
            ListViewItem item = ((ListView)sender).GetItemAt(e.X, e.Y);
            if (item != null && item.Tag == null)
            {
                ((ListView)sender).Invalidate(item.Bounds);
                item.Tag = "tagged";
            }
        }
    }
}
